<!-- 考勤统计 -->
<template>
  <a-card :bordered="false">
    <a-form layout="inline" @keyup.enter.native="searchQuery">
      <a-form-item label="方案编码">
        <a-input v-model="queryParam.templateCode" />
      </a-form-item>
      <a-form-item label="方案名称">
        <a-input v-model="queryParam.templateName" />
      </a-form-item>
      <a-form-item>
        <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
        <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
      </a-form-item>
    </a-form>
    <vxe-grid
      id="SocialSecurity"
      ref="vxeTable"
      v-bind="options"
      :columns="columns"
      :data="dataSource"
      @toolbar-button-click="toolbarButtonClickEvent"
      @checkbox-all="onSelectChange"
      @checkbox-change="onSelectChange"
    >
      <template v-slot:toolbar_buttons>
        <a-button type="primary" icon="plus" style="margin:0px 8px 0px 0px;" @click="handleAdd">新增</a-button>
        <a-dropdown v-if="selectionRows.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
          </a-menu>
          <a-button>批量操作<a-icon type="down" /></a-button>
        </a-dropdown>
      </template>
      <template v-slot:operate="{ row }">
        <a @click="handleEdit(row)">编辑</a>
        <a-divider type="vertical" />
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(row.id)">
          <a>删除</a>
        </a-popconfirm>
      </template>
      <template v-slot:pager>
        <vxe-pager
          :layouts="layouts"
          :current-page.sync="ipagination.currentPage"
          :page-size.sync="ipagination.pageSize"
          :total="ipagination.total"
          @page-change="handlePageChange"
        >
        </vxe-pager>
      </template>
    </vxe-grid>
    <SocialSecurityModal ref="modalForm" @ok="modalFormOk"/>
  </a-card>
</template>
<script >
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
import SocialSecurityModal from './modal/SocialSecurityModal'
import { VxeTableMixin } from '@/mixins/VxeTableMixin'
import { filterDictTextByCache } from '@/components/dict/JDictSelectUtil'
export default {
  name: 'SocialSecurity',
  mixins: [VxeTableMixin],
  components: {
    JSelectUserByDep,
    SocialSecurityModal
  },
  data() {
    return {
      columns: [
        { type: 'checkbox', width: 50 },
        { type: 'seq', width: 60 },
        { field: 'templateCode', title: '方案编码' },
        { field: 'templateName', title: '方案名称' },
        { field: 'baseCity', title: '缴纳城市', slots: { default: ({ row }) => {
          return filterDictTextByCache('hr_base_city', row.baseCity)
        } }},
        { field: 'templateStatus', title: '状态', slots: { default: ({ row }) => {
          return row.templateStatus ? '生效' : '失效'
        } }},
        { field: 'operate', title: '操作', align: 'center', width: 100, slots: { default: 'operate' }}
      ],
      url: {
        list: '/hr/insurance/template/list',
        delete: '/hr/insurance/template/delete',
        deleteBatch: '/hr/insurance/template/deleteBatch'
      }
    }
  },
  methods: {
    handleEditRule(row) {
      this.$refs.ruleModal.edit()
    }
  }
}
</script>
